/*     */ package com.zimbra.cs.store;
/*     */ 
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import java.io.IOException;
/*     */ import java.io.InputStream;
/*     */ import java.io.OutputStream;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class BufferingIncomingBlob
/*     */   extends IncomingBlob
/*     */ {
/*     */   protected final String id;
/*     */   protected BlobBuilder blobBuilder;
/*     */   private Object ctx;
/*     */   private long expectedSize;
/*     */   private boolean expectedSizeSet;
/*     */   protected long lastAccessTime;
/*     */   
/*     */   protected BufferingIncomingBlob(String id, BlobBuilder blobBuilder, Object ctx)
/*     */   {
/*  40 */     this.id = id;
/*  41 */     this.blobBuilder = blobBuilder;
/*  42 */     this.ctx = ctx;
/*     */     
/*  44 */     this.lastAccessTime = System.currentTimeMillis();
/*     */   }
/*     */   
/*     */ 
/*     */   public String getId()
/*     */   {
/*  50 */     return this.id;
/*     */   }
/*     */   
/*     */   public OutputStream getAppendingOutputStream()
/*     */     throws IOException
/*     */   {
/*  56 */     this.lastAccessTime = System.currentTimeMillis();
/*  57 */     return new BlobBuilderOutputStream(this.blobBuilder);
/*     */   }
/*     */   
/*     */   public InputStream getInputStream()
/*     */     throws IOException
/*     */   {
/*  63 */     if (!$assertionsDisabled) throw new AssertionError("Not yet implemented");
/*  64 */     return null;
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */   public Object getContext()
/*     */   {
/*  71 */     return this.ctx;
/*     */   }
/*     */   
/*     */ 
/*     */   public void setContext(Object value)
/*     */   {
/*  77 */     this.ctx = value;
/*     */   }
/*     */   
/*     */   public long getCurrentSize()
/*     */     throws IOException
/*     */   {
/*  83 */     return this.blobBuilder.getTotalBytes();
/*     */   }
/*     */   
/*     */ 
/*     */   public boolean hasExpectedSize()
/*     */   {
/*  89 */     return this.expectedSizeSet;
/*     */   }
/*     */   
/*     */ 
/*     */   public long getExpectedSize()
/*     */   {
/*  95 */     assert (this.expectedSizeSet) : "Expected size not set";
/*  96 */     return this.expectedSize;
/*     */   }
/*     */   
/*     */ 
/*     */   public void setExpectedSize(long value)
/*     */   {
/* 102 */     assert (!this.expectedSizeSet) : ("Expected size already set: " + this.expectedSize);
/* 103 */     this.expectedSize = value;
/* 104 */     this.expectedSizeSet = true;
/*     */   }
/*     */   
/*     */ 
/*     */   public long getLastAccessTime()
/*     */   {
/* 110 */     return this.lastAccessTime;
/*     */   }
/*     */   
/*     */   public Blob getBlob() throws IOException, ServiceException
/*     */   {
/* 115 */     return this.blobBuilder.finish();
/*     */   }
/*     */   
/*     */   public void cancel()
/*     */   {
/* 120 */     this.blobBuilder.dispose();
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/store/BufferingIncomingBlob.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */